package think.in.spring.bean;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

/**
 * 01单一类型依赖查找
 * + 单一类型依赖查找接口--BeanFactory
 *   + 根据Bean名称查找
 *     + getBean(String)
 *     + getBean(String,Object...)
 *   + 根据Bean类型查找
 *     + Bean实时查找
 *       + getBean(Class)
 *       + getBean(Class,Object...)
 *     + Bean延迟查找(5.1)
 *       + getBeanProvider(Class)
 *       + getBeanProvider(ResolvableType)
 *   + 根据Bean名称+类型查找
 *     + getBean(String,Class)
 */
public class SingleTypeDependencyLookup {

    @Bean(name="one")
    public Integer one() {
        return 1;
    }

    @Bean
    public Float floatType() {
        return 1.3F;
    }

    @Bean
    public Double doubleType() {
        return 2.5D;
    }

    /**
     * 构造多个List
     * @return
     */
    @Bean
    public List<String> list1() {
        List<String> list1 = new ArrayList<>();
        list1.add("1");
        return list1;
    }

    @Bean
    public List<String> list2() {
        List<String> list2 = new ArrayList<>();
        list2.add("2");
        return list2;
    }
}
